
package com.csc440.team2.activity;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;


import com.csc440.team2.SmilConstants;
import com.csc440.team2.smil.SMILMessage;


public class MainMenu extends ListActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setListAdapter(new ArrayAdapter<String>(this, R.layout.first_menu, MENUOPTIONS));

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener()
        {
            public void onItemClick(AdapterView<?> parent, View clickedView, int position, long clickedItemId)
            {
                // have to set the new view
                if (position == SmilConstants.SELECTION_NEW_MESSAGE)
                {
                    SMILMessage message = SMILMessage.create();

                    //changed the intent redirection
                    Intent in = new Intent(MainMenu.this, ComponentsTest.class);
                    in.putExtra(SmilConstants.MESSAGE, message);
                    MainMenu.this.startActivity(in);
                }
                else if (position == SmilConstants.SELECTION_INBOX)
                {
                    Intent in = new Intent(MainMenu.this, Inbox.class);
                    MainMenu.this.startActivity(in);
                }
                else if (position == SmilConstants.SELECTION_SENT_ITEMS)
                {
                    Intent in = new Intent(MainMenu.this, SentItems.class);
                    MainMenu.this.startActivity(in);
                }
            }
        });
    }

    final static String[] MENUOPTIONS = new String[] {
            "NEW MESSAGE", "INBOX", "SENT ITEMS"
    };
}